home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.lang.c
- Subject: Re: Q.: How does strtol() handles overflows?
- Date: 09 Jan 1996 21:12:02 GMT
- Organization: Computer People Inc.
- Message-ID: <ALUN.CHAMPION.96Jan9161202@g7240065.bridge.bst.bls.com>
- References: <4cuc2h$gup@news.netvision.net.il>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: simchoni@netvision.net.il's message of 9 Jan 1996 18:27:29 GMT
-
- In article <4cuc2h$gup@news.netvision.net.il> simchoni@netvision.net.il (Ami Simchoni) writes:
-
- : I am trying to make a rubust ascii-to-decimal function which handles
- : input errors and overflows. I want to rely on the standard library as
- : much as possible.
-
- : Borland C++ 3.1 and 4.02 doumentation says if an overflow occurs strtol
- : just returns zero - which is not satisfactory, of course.
-
- : The BC++3.1 library source which I have, however, sets errno to ERANGE
- : and returns LONG_MIN or LONG_MAX on overflow. This appears both in the
- : code and in the comments.
-
- : Does anybody know what the standard says about it?
-
- Yeah. It says exactly what the library source does.
-
- 7.10.1.5 The strtol function
- ...
- Returns
- The strtol function returns the converted value, if any. If no conversion
- could be performed, zero is returned. If the correct value is outside the
- range of representable values, LONG_MAX or LONG_MIN is returned (according to
- the sign of the value), and the value of the macro ERANGE is stored in errno.
-
- Et voila
- Regards
-
- -A.
- --
- | A.Champion |
-